layui
		.use(
				[ 'form', 'layer', 'laydate' ],
				function() {
					var form = layui.form, laydate = layui.laydate, layer = parent.layer === undefined ? layui.layer
							: top.layer, $ = layui.jquery;

					laydate.render({
						elem : '#admissionDate' // 渲染日历input
					});

					form.on("submit(addDormBuild)", function(data) {

						// 弹出loading
						var index = top.layer.msg('数据提交中，请稍候', {
							icon : 16,
							time : false,
							shade : 0.8
						});
						var dormBuildId = $("#dormBuildId").val();
						console.log(dormBuildId);
						if (dormBuildId == null || dormBuildId == "") {
							dormBuildId = 0;
						}
						$.ajax({
							type : 'post',
							url : '/dormbuild/add.html',
							data : {
								opType : $("#opType").val(),
								dormBuildId : dormBuildId,
								dormBuildName : $(".dormBuildName").val(),
								detail : $('.detail').val(),
							},
							timeout : 2000,
							success : function(msg) {
								top.layer.close(index);
								if (msg == true) {
									if ($("#opType").val() == 1) {// 是修改操作
										// 修改成功则刷新父页面
										layer.closeAll("iframe");
										parent.location.reload();
									} else {
										top.layer.msg("操作成功！");
										parent.location.reload();
									}
								} else {
									layer.msg(msg, {
										icon : 5,
										time : 1000
									});
								}
							},
							error : function() {
								layer.msg("操作失败！", {
									icon : 5,
									time : 1000
								});
								layer.close(index);
							}
						});
						return false;
					});
				});